package ma.co.ba.BusinessApplications.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "DATS")
public class DAT implements Serializable {
	private static final long serialVersionUID = 1L;

	@Transient
	FamilleDeProduit familleDeProduit;
	@Transient
	boolean affect;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	@Column(name = "TITRE", length = 250)
	private String titre;

	@Column(name = "DESCRIPTION", length = 5000)
	private String description;

	@Column(name = "DATE_OUVERTURE")
	private Date dateOuverture = new Date();

	@Column(name = "DATE_RESOLUTION")
	private Date dateResolution;

	@Column(name = "DATE_RESOLUTION_PREVUE")
	private Date dateResolutionPrevue;

	@Column(name = "DUREE_NECESSAIRE")
	private int duree;

	@Column(name = "ACTIVE")
	private boolean active = true;

	@ManyToOne(fetch = FetchType.EAGER)
	private Criticite criticite;

	@ManyToOne(fetch = FetchType.EAGER)
	private Contact contact;

	@ManyToOne(fetch = FetchType.EAGER)
	private Client client;

	@ManyToOne(fetch = FetchType.EAGER)
	private Etat etat;

	@ManyToOne(fetch = FetchType.EAGER)
	private Produit produit;

	@OneToMany(mappedBy = "dat", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Intervention> interventions;

	@ManyToOne(fetch = FetchType.EAGER)
	private Utilisateur consultantAffecte;

	public DAT() {
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getDateResolution() {
		return dateResolution;
	}

	public void setDateResolution(Date dateResolution) {
		this.dateResolution = dateResolution;
	}

	public Criticite getCriticite() {
		return criticite;
	}

	public void setCriticite(Criticite criticite) {
		this.criticite = criticite;
	}

	public Contact getContact() {
		return contact;
	}

	public void setContact(Contact contact) {
		this.contact = contact;
	}

	public Etat getEtat() {
		return etat;
	}

	public void setEtat(Etat etat) {
		this.etat = etat;
	}

	public Produit getProduit() {
		return produit;
	}

	public void setProduit(Produit produit) {
		this.produit = produit;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public FamilleDeProduit getFamilleDeProduit() {
		return familleDeProduit;
	}

	public void setFamilleDeProduit(FamilleDeProduit familleDeProduit) {
		this.familleDeProduit = familleDeProduit;
	}

	public String getTitre() {
		return titre;
	}

	public void setTitre(String titre) {
		this.titre = titre;
	}

	public Date getDateOuverture() {
		return dateOuverture;
	}

	public void setDateOuverture(Date dateOuverture) {
		this.dateOuverture = dateOuverture;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public List<Intervention> getInterventions() {
		return interventions;
	}

	public void setInterventions(List<Intervention> interventions) {
		this.interventions = interventions;
	}

	public Utilisateur getConsultantAffecte() {
		return consultantAffecte;
	}

	public void setConsultantAffecte(Utilisateur consultantAffecte) {
		this.consultantAffecte = consultantAffecte;
	}

	public boolean isAffect() {
		return affect;
	}

	public void setAffect(boolean affect) {
		this.affect = affect;
	}

	public Date getDateResolutionPrevue() {
		return dateResolutionPrevue;
	}

	public void setDateResolutionPrevue(Date dateResolutionPrevue) {
		this.dateResolutionPrevue = dateResolutionPrevue;
	}

	public int getDuree() {
		return duree;
	}

	public void setDuree(int duree) {
		this.duree = duree;
	}

}